package YAVMM::CLI::Plugin::Guest;
use Moose::Role;

use YAVMM::GuestManager;
use YAVMM::GuestDB;

use TryCatch;

sub start_guest {
    my $self = shift;

    try {
	my $result = $self->_rpc_call(
	    'guest_start',
	    name => $self->options->{name},
	    host => $self->options->{host},
	);
    } catch (YAVMM::Error $err) {
	$self->log->error("Unable to start guest: $err");
    }
}

sub stop_guest {
    my $self = shift;

    try {
	my $result = $self->_rpc_call(
	    'guest_stop',
	    name => $self->options->{name},
	);
    } catch (YAVMM::Error $err) {
	$self->log->error("Unable to start guest: $err");
    }
}

sub kill_guest {
    my $self = shift;

    try {
	my $result = $self->_rpc_call(
	    'guest_kill',
	    name => $self->options->{name},
	);
    } catch (YAVMM::Error $err) {
	$self->log->error("Unable to kill guest: $err");
    }
}

sub migrate_guest {
    my $self = shift;

    try {
	my $result = $self->_rpc_call(
	    'guest_migrate',
	    name => $self->options->{name},
	    host => $self->options->{host},
	);
    } catch (YAVMM::Error $err) {
	$self->log->error("Unable to migrate guest: $err");
    }
}

1;
